package by.pavlyukevich.paymentsystem.panel;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeAction;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.ResourceModel;

@AuthorizeAction(action = "RENDER", roles = { "SIGNED_IN" })
public class NavigationPanel extends Panel {
	private Pair<ResourceModel, WebPage> labelPage;

	public NavigationPanel(String id, Pair<ResourceModel, WebPage> labelPage) {
		super(id);
		this.labelPage = labelPage;
	}

	@Override
	protected void onInitialize() {
		super.onInitialize();
		WebMarkupContainer liContainer = new WebMarkupContainer("nm-item");
		add(liContainer);
		Link<Void> liHref = new Link<Void>("nmi-href") {
			@Override
			public void onClick() {
				setResponsePage(labelPage.getRight());
			}
		};

		liContainer.add(liHref);
		liHref.add(new Label("nmi-label", labelPage.getLeft()));

	}

}
